package com.dhwl.hsh.merchant.ui.dialog;

import android.app.DialogFragment;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;

import com.dhwl.hsh.merchant.R;
import com.dhwl.hsh.merchant.ui.activity.LoginActivity;
import com.umeng.analytics.MobclickAgent;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * 简要描述
 *
 * @author Derek.Kidd
 * @version V1.0.0
 * @date 2016-04-28 20:50
 */
public class LogoutDialogFragment extends DialogFragment {

    @Bind(R.id.dialog_btn_cancel)
    Button dialogBtnCancel;
    @Bind(R.id.dialog_btn_sure)
    Button dialogBtnSure;

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setStyle(android.support.v4.app.DialogFragment.STYLE_NORMAL, R.style.loading_dialog);
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

        View v = inflater.inflate(R.layout.dialog_logout, container, false);
        ButterKnife.bind(this, v);
        getDialog().setCanceledOnTouchOutside(false);
        return v;

    }

    @OnClick(R.id.dialog_btn_sure)
    public void onSureClick(View view) {
        Intent intent  =new Intent (getActivity(),LoginActivity.class);
        intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        getActivity().startActivity(intent);
        //umeng 数据账号统计
        MobclickAgent.onProfileSignOff();
    }

    @OnClick(R.id.dialog_btn_cancel)
    public void onCancelClick(View view) {
      dismissAllowingStateLoss();
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        ButterKnife.unbind(this);
    }
}
